/*
 * @Author: @AT-bear 1509109728@qq.com
 * @Date: 2024-06-05 21:07:14
 * @LastEditors: @AT-bear 1509109728@qq.com
 * @LastEditTime: 2024-06-29 04:05:24
 * @FilePath: \riddle_game_server\controller\apiController.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
'use strict';
const BaseURL = 'http://127.0.0.1:2024'

let successState = 200;
let failState=500;
//查询谜题
exports.getRiddles = async (req,res) => {
  let sql = `SELECT question,option1 as OA,option2 as OB,option3 as OC,answer from riddles ORDER BY RAND() LIMIT 5`

  const data = await res.exeSql(sql)

  res.send({
    status:successState,
    message:data.rows
  })
}

exports.get =async (req, res) => {
    res.send({
        status:successState,
        message:'你好'
    })
}

//查询歇后语
exports.getIdiom = async (req,res) => {
  let sql = `SELECT * from idiom ORDER BY RAND() LIMIT 5`

  const data = await res.exeSql(sql)

  res.send({
    status:successState,
    message:data.rows
  })
}

//查询简单题
exports.getSimple = async (req,res) => {
  let sql = `SELECT * from riddles_jian ORDER BY RAND() LIMIT 5`

  const data = await res.exeSql(sql)

  res.send({
    status:successState,
    message:data.rows
  })
}